﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;

/// <summary>
/// Summary description for SendEmail
/// </summary>
public class SendEmail
{
    public static void sendMailRegister(string toEmail,string name, string username, string matkhau)
    {
        string from = "dealbaby22@gmail.com";
        string to = toEmail;
        string subject = "Chào mừng " + name + " đến với website babydeal";
        string body = "Hi " + name + ", <br><br>" + "Bạn đã đăng kí thành công tại babydeal! Thông tin tài khoản cá nhân của bạn là: <br><br>Username : " + username + "<br>Mật khẩu: " + matkhau + "<br><br>Thân";
        sendMailall(from, to, subject, body);
    }
    public static void sendMailAds(string toEmail, string name, string tieude, string noidung)
    {
        string from = "dealbaby22@gmail.com";
        string to = toEmail;
        string subject = "[BabyDeal] "+ tieude;
        string body = "Hi " + name + ", <br>BabyDeal đang có khuyến mãi mới!<br><br>-------------------------------------------<br>"+ noidung +"<br><br>Thân";
        sendMailall(from, to, subject, body);
    }
    public static void sendMailall(string from, string to, string subject, string body)
    {
        MailMessage mail = new MailMessage();
        mail.To.Add(to);
        mail.From = new MailAddress(from);
        mail.Subject = subject;
        mail.Body = body;
        mail.IsBodyHtml = true;
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com";
        smtp.Credentials = new System.Net.NetworkCredential("dealbaby22@gmail.com", "hoangvuhoangvu");
        smtp.EnableSsl = true;
        smtp.Send(mail);
    }
}